<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>

  <style>
    .box {
      width: 500px;
      height: 88px;
      background-color: lightblue;
    }
  </style>
</head>

<body>

  <p>
    post
  </p>
  <button class="btn1">走你~</button>

  <div class="box">
    查询结果如下：
  </div>

  <script>
    let box = document.getElementsByClassName('box')[0];
    let btn1 = document.getElementsByClassName('btn1')[0];


    btn1.onclick = function () {
      const xhr = new XMLHttpRequest();
      xhr.open('POST', 'http://127.0.0.1:8888/server', true);
      //设置请求头
      xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
      xhr.send('a=100&b=200&c=300')
      xhr.onreadystatechange = function () {
        if (xhr.readyState === 4) {
          if (xhr.status >= 200 && xhr.status < 300) {
            box.innerHTML = xhr.response;
          }
        }
      }
    }
  </script>
</body>

</html>